package com.frejoys.admin.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.frejoys.common.aop.Authority;
import com.frejoys.common.aop.Authorization;
import com.frejoys.common.constant.CommonConstant;
import com.frejoys.common.dto.admin.UserWalletListDto;
import com.frejoys.common.dto.admin.UserWalletLogListDto;
import com.frejoys.common.dto.app.UserWalletLogPageDto;
import com.frejoys.common.dto.common.IdDto;
import com.frejoys.common.response.Result;
import com.frejoys.common.vo.admin.UserWalletListLogVo;
import com.frejoys.common.vo.admin.UserWalletListVo;
import com.frejoys.common.vo.app.UserWalletLogPageVo;
import com.frejoys.service.UserWalletLogService;
import com.frejoys.service.UserWalletService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Tag(name = "用户钱包管理", description = "后台用户钱包管理")
@RestController
@RequiredArgsConstructor
@RequestMapping(CommonConstant.routePrefixAdmin)
@Authorization(Authority.Private)
public class AdminUserWalletController {

    private final UserWalletLogService userWalletLogService;

    private final UserWalletService userWalletService;


    //后台分页查询用户钱包信息
    @Operation(summary = "分页查询用户钱包提现记录")
    @PostMapping("/user/walletLog/page")
    public Result<Page<UserWalletLogPageVo>> walletLogPage(@RequestBody @Validated UserWalletLogPageDto dto) {
        return Result.success(userWalletLogService.walletLogPage(dto));
    }

    //后台审核用户提现
    @Operation(summary = "审核用户提现")
    @PostMapping("/user/walletLog/check")
    public Result checkUserWalletLog(@RequestBody @Validated IdDto dto) {
        userWalletLogService.checkUserWalletLog(dto);
        return Result.success();
    }


    @Operation(summary = "查询用户钱包列表")
    @PostMapping("/user/walletLog/walletList")
    public Result<IPage<UserWalletListVo>> walletList(@RequestBody @Validated UserWalletListDto dto) {
        return Result.success(userWalletService.walletList(dto));
    }

    @Operation(summary = "查询用户钱包日志列表")
    @PostMapping("/user/walletLog/walletLogList")
    public Result<IPage<UserWalletListLogVo>> walletLogList(@RequestBody @Validated UserWalletLogListDto dto) {
        return Result.success(userWalletLogService.walletLogList(dto));
    }
}
